﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using My.Admin.Dto.System;
using My.Admin.Enum;
using My.Admin.Model;
using My.Admin.Model.System;
using My.Admin.Service.System;
using My.Admin.Service.System.IService;
using My.Core.CustomException;
using My.Core.DynamicWebApi.Attributes;
using My.Core.SqlSugar.model;

namespace My.Admin.Dynamic
{
	[Service("SysDictTypeController")]
	public class SysDictTypeController
	{
		private readonly ISysDictTypeService _sysDictTypeService;

		public SysDictTypeController(ISysDictTypeService sysDictTypeService)
		{
			_sysDictTypeService = sysDictTypeService;
		}

		/// <summary>
		/// 获取字典类型分页列表
		/// </summary>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task<PagedInfo<SysDictType>> Page(PageDictTypeInput input)
		{
			return await _sysDictTypeService.Page(input);
		}

		/// <summary>
		/// 获取字典类型列表
		/// </summary>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<List<SysDictType>> GetList()
		{
			return await _sysDictTypeService.GetList();
		}

		/// <summary>
		/// 获取字典类型-值列表
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<List<SysDictData>> GetDataList([FromQuery] GetDataDictTypeInput input)
		{
			return await _sysDictTypeService.GetDataList(input);
		}

		/// <summary>
		/// 添加字典类型
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task AddDictType(AddDictTypeInput input)
		{
			await _sysDictTypeService.AddDictType(input);
		}

		/// <summary>
		/// 更新字典类型
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task UpdateDictType(UpdateDictTypeInput input)
		{
			await _sysDictTypeService.UpdateDictType(input);
		}

		/// <summary>
		/// 删除字典类型
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task DeleteDictType(DeleteDictTypeInput input)
		{
			await _sysDictTypeService.DeleteDictType(input);
		}

		/// <summary>
		/// 获取字典类型详情
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<SysDictType> GetDetail([FromQuery] DictTypeInput input)
		{
			return await _sysDictTypeService.GetDetail(input);
		}

		/// <summary>
		/// 修改字典类型状态
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		[Authorize]
		[HttpPost]
		public async Task SetStatus(DictTypeInput input)
		{
			await _sysDictTypeService.SetStatus(input);
		}

		/// <summary>
		/// 获取所有字典集合
		/// </summary>
		/// <returns></returns>
		[Authorize]
		[HttpGet]
		public async Task<List<SysDictType>> GetAllDictList()
		{
			return await _sysDictTypeService.GetAllDictList();
		}
	}
}
